'
该场景用于控制游戏保存的各个节点
'

extends Node

@onready var game_save: Node = $GameSave
@onready var options_save: Node = $OptionsSave


#在准备函数中加载所有文件，绑定经验收集信号以便时时存储
func _ready() -> void:
	GameEvents.experience_collected.connect(on_experience_collected)
	game_save.load_save()
	options_save.load_save()
	pass

#保存数据，传入保存的数据类型
func save(save_name:String = "game_save") -> void:
	if save_name == "game_save":
		game_save.save()
	elif save_name == "options_save":
		options_save.save()
	pass

'game_data数据'
#增加一种局外升级
func add_external_upgrade(upgrade: ExternalUpgrade) -> void:
	game_save.add_external_upgrade(upgrade)
	pass

#返回传入升级ID的等级
func get_upgrade_quantity(upgrade_id: String) -> int:
	return game_save.get_upgrade_quantity(upgrade_id)

#返回物品数量
func get_quantity(id:String) -> int:
	return game_save.get_quantity(id)

#收集经验时通知子节点
func on_experience_collected(number: int) -> void:
	game_save.experience_collected(number)
	pass

'options_data数据'
#返回选择菜单中的数据
func get_option_data(id:String):
	return options_save.get_data(id)

#设置选项属性
func set_options_data(id:String,content):
	options_save.set_data(id,content)
	pass
